// pages/personal/personal.js
var app = getApp();
var util = require('../../utils/util');
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        util.fetchPost("/api/v1/common/system", {}, function (res) {
            that.setData({
                kefu: res.datas.kefu_phone,
            })
        })
    },
	//结算须知
	onEttlementTap() {
		wx.navigateTo({
			url: '../settlement/settlement',
		})
	},

	//店铺  关闭和开启
	switch1Change(e){
		
		var show_status="";
		if (e.detail.value==false){
			show_status=0
		}else{
			show_status=1
		}
		var that = this;
		util.showLoading();
		var apiUrl = 'api/store/store/store_modify';
		var apiData = {
			show_status: show_status
		}
		util.fetchPost(apiUrl, apiData, function (res) {
			util.hideLoading();
			
		});
		console.log(show_status)
	},
    //上传商品
    uploadShoppTap:function(){
        wx.navigateTo({
            url: '../uploadShopp/uploadShopp',
        })
    },
    //我的收入
    myincomeTap:function(){
        wx.navigateTo({
            url: '../myincome/myincome?type=1',
        })
    },
    //修改店铺
    modifyshopTap:function(){
        wx.navigateTo({
            url: '../modifyshop/modifyshop',
        })
    },

	//跳入设置
	onSetUpTap:function(e){
		wx.navigateTo({
			url: "../setup/setup",
		})
	},
    //客服电话
    onPhoneTap: function (e) {
        var that = this;
        console.log()
        wx.makePhoneCall({
            phoneNumber: that.data.kefu //仅为示例，并非真实的电话号码
        })
    },
	//退出登录
	closeLoginTap: function (e) {
		wx.removeStorageSync("store_id");
		wx.removeStorage({
			key: 'pwdInfo',
			success: function (res) {
				wx.reLaunch({
					url: '../login/login',
				})
			},
		})
	},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var that = this;
        app.checkLogin(function(){
            that.getStoreInfo();
        })
    },
    getStoreInfo:function(){
        var that = this;
        util.showLoading();
        var apiUrl = '/api/store/store/index';
        var apiData = {
        }
        util.fetchPost(apiUrl,apiData,function(res){
            util.hideLoading();
            if(res.state == 1){
                that.setData({
                    store_info:res.datas
                });
            }else{
                util.message(res.datas);
            }
        });
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})